package net.maxupeng.asm74;

import net.maxupeng.asm74.antlr.ASM74Parser;

import java.util.HashMap;
import java.util.Map;

public class AddressMode {
    private static final Map<Class<?>, String> AMCtx2NameMap = new HashMap<>();

    static {
        AMCtx2NameMap.put(ASM74Parser.Am_defaultContext.class, "default");
        AMCtx2NameMap.put(ASM74Parser.Am_immContext.class, "imm");
        AMCtx2NameMap.put(ASM74Parser.Am_directContext.class, "direct");
        AMCtx2NameMap.put(ASM74Parser.Am_indirectContext.class, "indirect");
        AMCtx2NameMap.put(ASM74Parser.Am_direct_indexContext.class, "direct_index");
        AMCtx2NameMap.put(ASM74Parser.Am_indirect_indexContext.class, "indirect_index");
        AMCtx2NameMap.put(ASM74Parser.Am_index_indirectContext.class, "index_indirect");
    }

    public static String getAmName(ASM74Parser.AmContext amCtx) {
        return AMCtx2NameMap.get(amCtx.getChild(0).getClass());
    }
}
